-
Notifications
You must be signed in to change notification settings - Fork 16
Sync Main (autogenerated) #195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Rust: accept test changes for now
… query with a PrintAst name from QlRefInlineExpectations.
This allows the string of package feeds to be constructed once and used repeatedly in the parallel restore loop as well.
…a given set of feeds.
…us-id Docs: add guidance for `previous-id` metadata
JS: `got` package modeling
…stinlineexpect QL4QL: Exclude PrintAst like tests from being reported as having missing InlineExpectations.
In particular for `postForm` `putForm` `patchForm` `getUri`.
Co-authored-by: Asger F <[email protected]>
…rof-rewriting Java buildless: add buildless-maven variant with a wildcard mirrorOf spec
…-swift Misc: Add another path prefix to accept-expected-changes-from-ci.py
Rust: rename several entities to their more natural names
…e-bom-downloads Java: add test exercising Gradle download pruning
Merge rc/3.17 into main
Actions: rename changenote file
Javascript, add missing `*` to changenote
Release preparation for version 2.21.0
Compatible with the latest released version of the CodeQL CLI
if (nugetConfigs.Count > 0) | ||
{ | ||
// We don't have to get the feeds from each of the folders from below, it would be enought to check the folders that recursively contain the others. | ||
allFeeds = nugetConfigs | ||
.Select(config => | ||
{ | ||
logger.LogWarning($"Failed to get directory of '{config}': {exc}"); | ||
} | ||
return null; | ||
}) | ||
.Where(folder => folder != null) | ||
.SelectMany(folder => GetFeeds(() => dotnet.GetNugetFeedsFromFolder(folder!))) | ||
.ToHashSet(); | ||
try | ||
{ | ||
return new FileInfo(config).Directory?.FullName; | ||
} | ||
catch (Exception exc) | ||
{ | ||
logger.LogWarning($"Failed to get directory of '{config}': {exc}"); | ||
} | ||
return null; | ||
}) | ||
.Where(folder => folder != null) | ||
.SelectMany(folder => GetFeeds(() => dotnet.GetNugetFeedsFromFolder(folder!))) | ||
.ToHashSet(); | ||
} | ||
else | ||
{ | ||
// If we haven't found any `nuget.config` files, then obtain a list of feeds from the root source directory. | ||
allFeeds = GetFeeds(() => dotnet.GetNugetFeedsFromFolder(this.fileProvider.SourceDir.FullName)).ToHashSet(); | ||
} |
Check notice
Code scanning / CodeQL
Missed ternary opportunity Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 months ago
To fix the problem, we will replace the if
statement with a ternary operator to assign the value to the allFeeds
variable. We will also move the logging statements outside the ternary operator to ensure they are executed appropriately based on the condition.
- Replace the
if
statement on lines 821-845 with a ternary operator. - Move the logging statements to be executed based on the condition separately.
-
Copy modified lines R819-R820 -
Copy modified lines R835-R840 -
Copy modified line R844
@@ -818,8 +818,4 @@ | ||
// todo: this could be improved. | ||
HashSet<string>? allFeeds = null; | ||
|
||
if (nugetConfigs.Count > 0) | ||
{ | ||
// We don't have to get the feeds from each of the folders from below, it would be enought to check the folders that recursively contain the others. | ||
allFeeds = nugetConfigs | ||
HashSet<string>? allFeeds = nugetConfigs.Count > 0 | ||
? nugetConfigs | ||
.Select(config => | ||
@@ -838,3 +834,8 @@ | ||
.SelectMany(folder => GetFeeds(() => dotnet.GetNugetFeedsFromFolder(folder!))) | ||
.ToHashSet(); | ||
.ToHashSet() | ||
: GetFeeds(() => dotnet.GetNugetFeedsFromFolder(this.fileProvider.SourceDir.FullName)).ToHashSet(); | ||
|
||
if (nugetConfigs.Count > 0) | ||
{ | ||
logger.LogInfo($"Found {allFeeds.Count} Nuget feeds (with inherited ones) in nuget.config files: {string.Join(", ", allFeeds.OrderBy(f => f))}"); | ||
} | ||
@@ -842,8 +843,5 @@ | ||
{ | ||
// If we haven't found any `nuget.config` files, then obtain a list of feeds from the root source directory. | ||
allFeeds = GetFeeds(() => dotnet.GetNugetFeedsFromFolder(this.fileProvider.SourceDir.FullName)).ToHashSet(); | ||
logger.LogDebug("No Nuget feeds found in nuget.config files."); | ||
} | ||
|
||
logger.LogInfo($"Found {allFeeds.Count} Nuget feeds (with inherited ones) in nuget.config files: {string.Join(", ", allFeeds.OrderBy(f => f))}"); | ||
|
||
return (explicitFeeds, allFeeds); |
catch (Exception exc) | ||
{ | ||
logger.LogWarning($"Failed to get directory of '{config}': {exc}"); | ||
} |
Check notice
Code scanning / CodeQL
Generic catch clause Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 months ago
To fix the problem, we should catch only specific exceptions that are relevant to the operation being performed. In this case, since the code is dealing with file I/O operations, we should catch exceptions such as IOException
and UnauthorizedAccessException
. This will ensure that only relevant exceptions are caught, and other exceptions are not unintentionally masked.
- Identify the specific exceptions that are relevant to the file I/O operations.
- Replace the generic
catch (Exception exc)
block with specific catch blocks forIOException
andUnauthorizedAccessException
. - Ensure that the logging functionality remains the same to provide useful information in case of an exception.
-
Copy modified line R831 -
Copy modified lines R833-R837
@@ -830,5 +830,9 @@ | ||
} | ||
catch (Exception exc) | ||
catch (IOException ioExc) | ||
{ | ||
logger.LogWarning($"Failed to get directory of '{config}': {exc}"); | ||
logger.LogWarning($"Failed to get directory of '{config}' due to I/O error: {ioExc}"); | ||
} | ||
catch (UnauthorizedAccessException authExc) | ||
{ | ||
logger.LogWarning($"Failed to get directory of '{config}' due to unauthorized access: {authExc}"); | ||
} |
This PR syncs the latest changes from
codeql-cli/latest
intomain
.